const express = require('express')
const router = express.Router()

router.get('/user/permission', (req, res) => {
  const type = req.query.type
  let data
  if (type === 'admin') {
    data = {
      code: 200,
      data: [
        {
          id: '1',
          permissionName: 'sys:user:add',
          permissionContent: '权限指令添加权限',
          accessibleRoles: ['管理员']
        },
        {
          id: '2',
          permissionName: 'sys:user:edit',
          permissionContent: '权限指令修改权限',
          accessibleRoles: ['管理员']
        },
        {
          id: '3',
          permissionName: 'sys:user:delete',
          permissionContent: '权限指令删除权限',
          accessibleRoles: ['管理员']
        },
        {
          id: '4',
          permissionName: 'orderHistory:table',
          permissionContent: '订单记录/订单管理页面表格展示权限',
          accessibleRoles: ['管理员', '普通用户']
        }
      ],
      msg: '请求成功'
    }
  } else if (type === 'user') {
    data = {
      code: 200,
      data: ['sys:user:add', 'sys:user:edit'],
      msg: '请求成功'
    }
  }
  res.json(data)
})

module.exports = router
